from abc import ABCMeta,abstractmethod

#抽象产品：让具体产品有同样的表现和使用
class Payment(metaclass=ABCMeta):
    #abstract class
    @abstractmethod
    def pay(self,money):
        pass
#具体产品
class Alipay(Payment):
    def __init__(self,use_huabei=False):
        self.use_huabei=use_huabei

    def pay(self,money):
        if self.use_huabei==True:
            print("花呗支付%d元"%money)
        else:
            print("支付宝余额支付%d元"%money)

class WechatPay(Payment):
    def pay(self,money):
        print("微信支付%d元"%money)
class BankPay(Payment):
    def pay(self,money):
        print("用银行支付%d元"%money)

#工厂角色（Creator）
class PaymentFactory(metaclass=ABCMeta):
    @abstractmethod
    def create_payment(self):
        pass

class AlipayFactory(PaymentFactory):
    def create_payment(self):
        return Alipay()

class WechatPayFactory(PaymentFactory):
    def create_payment(self):
        return WechatPay()

class HuabeiFactory(PaymentFactory):
    def create_payment(self):
        return Alipay(use_huabei=True)

class BankPayFactory(PaymentFactory):
    def create_payment(self):
        return BankPay()


#client
pf=HuabeiFactory()
pf1=BankPayFactory()
p1=pf1.create_payment()
p=pf.create_payment()
p.pay(100)
p1.pay(200)